<template>
<div>
  <dialog-form
    style="width: 600px"
    v-model="dialogVisible"
    title="发布文章"
    :draft-essay-button = 'true'
    :release-essay-button = 'true'
    :cancel-button="true"
    @releaseEssay="releaseEssayHandler"
    @draftEssay="draftEssayHandler"
  >
    <template #content>
      <article-base-info-form v-model="value" ref="articleBaseInfoForm"/>
    </template>
  </dialog-form>
</div>
</template>

<script>
import DialogForm from '@/components/dialog/DialogForm'
import { ref } from 'vue'
import ArticleBaseInfoForm from '@/views/programming/article/form/base/article-base-info-form'
import { articleDraft, articleRelease } from '@/api/article'
export default {
  name: 'article-writing-release',
  components: { ArticleBaseInfoForm, DialogForm },
  props: ['modelValue'],
  computed: {
    value: {
      get () {
        return this.modelValue
      },
      set (value) {
        this.$emit('update:modelValue', value)
      }
    }
  },
  setup () {
    return {
      dialogVisible: ref(false)
    }
  },
  methods: {
    releaseEssayHandler () {
      console.log('发布')
      articleRelease(this.value).then(val => {
        console.log(val)
      })
    },
    draftEssayHandler () {
      console.log(this.value)
      console.log('保存为草稿')
      articleDraft(this.value).then(value => {
        console.log(value)
      })
    }
  }
}
</script>

<style scoped>

</style>
